package com.chuck.blogpro.mapper;

import com.chuck.blogpro.pojo.Article;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ArticleMapper {


    //  1. 自己写的话是这样的
    @Select("select count(*) from t_article")
    Long getTotal();

    @Select("select * from t_article")
    List<Article> list();


    // 2. 使用 page helper 管理直接返回列表，会被包装到 pageBean 中
    @Select("select * from t_article limit #{startIndex},#{pageSize}")
    List<Article> page(Integer startIndex, Integer pageSize);

    @Delete("delete from t_article where id = #{id}")
    void delete(Integer id);

    void add(Article article);

    void update(Article article);

    Article getArticleById(Integer id);
}
